<?php
/**
 * 统一处理入口
 */
class handler {
	
	private $_BY = 0;
	
	/**
	 *  type 
	 *  1 	时
	 *  2	天
	 *  3 	周
	 * 	4	月
	 */
	public function __construct($type = null) {
		$byParams = array(BY_HOUR,BY_DAY,BY_WEEK,BY_MONTH);
		if(in_array($type,$byParams)){
			$this->_BY = $type;
		}
	}

	public function deal(){
		$BY = "";
		switch($this->_BY){
			case BY_HOUR:$BY="hour";break;
			case BY_DAY:$BY="day";break;
			case BY_WEEK:$BY="week";break;
			case BY_MONTH:$BY="month";break;
			default :exit;break;
		}
		
		$params = array('nowTime'=>time());
		$dir	= CRON_PATH."/dispatch/$BY/";
		
		$arrRequireC = get_dir_files($dir);
		
		foreach($arrRequireC as $c){
			$classfile = $dir."$c.class.php";
			if(file_exists($classfile)){
				require_once($classfile);
				call_user_func(array($c, "do_handler"),$params);
			}
		}
	}
}
?>